"use strict";
cc._RF.push(module, '347b4VBAmJH6pw0+hrVEwY7', 'enemyHit');
// script/game/enemyHit.js

"use strict";

cc.Class({
  "extends": cc.Component,
  properties: {
    daggerPrefab: {
      "default": null,
      type: cc.Prefab
    }
  },
  onLoad: function onLoad() {
    this.dagger = null;
    this.daggerNode = cc.instantiate(this.daggerPrefab);
    this.enemy = this.node.parent.getComponent('enemy'); // this.hp = this.enemy.hp;
  },
  show: function show() {
    this.dagger.active = true;
  },
  hide: function hide() {
    this.dagger.active = false;
  },
  //碰撞回调
  onCollisionEnter: function onCollisionEnter(other, self) {
    // console.log(self);
    if (other.node.group == 'role' && other.tag == 1) {
      this.enemy.isHurt();
      return;
    }

    if (other.node.group == 'dagger' && other.tag == 2) {
      if (this.dagger) {
        this.enemy.isHurt();
        this.hide();
        this.dagger.removeFromParent();
      } else {
        console.log("找不到该节点");
      }
    }
  },
  update: function update(dt) {
    this.dagger = cc.find("Canvas/dagMain"); // this.degger = this.dagger;
  }
});

cc._RF.pop();